package com.apptonelabs.android.view;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.apptonelabs.android.R;
import com.apptonelabs.android.model.PNRType;

public class PNREntryAdapter extends ArrayAdapter<String> {
	private final Context context;
	private final List<String> values;

	public PNREntryAdapter(Context context, List<String> values, PNRType type) {
		super(context, R.layout.pnr, values);
		this.context = context;
		this.values = values;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View rowView = inflater.inflate(R.layout.pnr, parent, false);
		TextView textView = (TextView) rowView.findViewById(R.id.pnrLableTV);
		//ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);

		// Position == 0 should be the Title of the Activity
		if (position == 0) {
			parent.setBackgroundColor(Color.parseColor("#000000"));
			
			// Font settings
			textView.setTextSize(18F);
			
			//imageView.setImageResource(R.drawable.ic_launcher);
			String text = "<font color=#ffffff><b>Indian Railway PNR Status</b></font>";
			textView.setText(Html.fromHtml(text));
			return rowView;
		}
		
		if(values.get(position).contains("Passengers")) {
			rowView.setBackgroundColor(Color.parseColor("#838383"));
		} else if(values.get(position).contains("Passenger")) {
			rowView.setBackgroundColor(Color.parseColor("#535353"));
		}

		// Font settings
		textView.setTextSize(16F);
		textView.setText(Html.fromHtml(values.get(position)));

		return rowView;
	}
}